export default {
  // Global page headers (https://go.nuxtjs.dev/config-head)
  head: {
    title: 'nuxt01',
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: 'SEO优化页面自定义描述信息' }
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
    ]
  },

  // 配置middleware,auth为middleware目录下的auth.js
  router: {
    middleware: 'auth',
    // 添加扩展路由
    extendRoutes(routes,resolve){
      console.log(routes) // 打印所有路由
      routes.push({
        name: 'home', // 组件名称
        path: '/index', // 组件路径
        // __dirname 表示nuxt.cofnig.js位置或路径，后面是组件的相对路径
        component: resolve(__dirname,'pages/index.vue')
      })
    }
  },

  // 定义系统默认的loading效果，或者指定loading组件
  // loading: {color: '#399',height: '3px'},
  loading: '~/components/loading.vue',

  // Global CSS (https://go.nuxtjs.dev/config-css)
  // 全局样式配置，下面的路径都是相对于nuxt.config.js的相对路径
  css: [
    'assets/css/transition.css',
    'assets/css/base.css'
  ],

  // Plugins to run before rendering page (https://go.nuxtjs.dev/config-plugins)
  plugins: [
    '~/plugins/router',
    {
      src: '~/plugins/axios',
      ssr: true //开启服务器端渲染
    },
    {
      src:"~/plugins/element-ui",
      ssr:true, //不支持ssr的插件只会在客户端运行不要给true
      // mode:'server'//client  // v2.4+
    },
    '~/plugins/mixins', // 引入自定义插件
  ],

  // Auto import components (https://go.nuxtjs.dev/config-components)
  components: true,

  // Modules for dev and build (recommended) (https://go.nuxtjs.dev/config-modules)
  buildModules: [
  ],

  // Modules (https://go.nuxtjs.dev/config-modules)
  modules: [
    '@nuxtjs/axios',
    'cookie-universal-nuxt',
    '@nuxtjs/style-resources'
    // 'element-ui/lib/theme-chalk/index.css',
    // 'assets/css/base.css',
  ],

  styleResources:{
    scss:[
      '~assets/scss/global.scss'
    ]
  },

  axios: {
    proxy: true, // 开启axios跨域功能
    //prefix: '', // 配置请求url前缀
  },

  proxy: {
    // 配置代理转发地址
    '/eduservice/': {
      target: 'http://120.79.234.144:9002', // 目标url
      changeOrigin: true, // 切换域
      pathRewrite: {
        // '^/teacher': ''  // url中以teacher开头的将其替换成空
      }
    },
    '/admin/': {
      target: 'http://120.79.234.144:9002', // 目标url
      changeOrigin: true, // 切换域
      pathRewrite: {
        // '^/teacher': ''  // url中以teacher开头的将其替换成空
      }
    }
  },

  // Build Configuration (https://go.nuxtjs.dev/config-build)
  build: {
    // transpile:[/^element-ui/],
    babel: {
      "plugins": [
        [
          "component",
          {
            "libraryName": "element-ui",
            "styleLibraryName": "theme-chalk"
          }
        ]
      ]
    }
  }
}
